﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Shove.Web.UI;

public partial class UserControls_TopMenu : UCBase
{
    public UserControls_TopMenu()
    {
        Name = "顶部菜单栏";

        swpas = new ShoveWebPartAttribute[10];

        swpas[0] = new ShoveWebPartAttribute_Int("控件宽度", "1,1000", 930, "控件宽度");
        swpas[1] = new ShoveWebPartAttribute_Int("Logo图片宽度", "1,500", 230, "Logo图片宽度");
        swpas[2] = new ShoveWebPartAttribute_Int("Logo图片高度", "1,500", 50, "Logo图片高度");
        swpas[3] = new ShoveWebPartAttribute_Int("联系电话图片宽度", "1,500", 310, "联系电话图片宽度");
        swpas[4] = new ShoveWebPartAttribute_Int("联系电话图片高度", "1,500", 33, "联系电话图片高度");

        swpas[5] = new ShoveWebPartAttribute_Text("排版样式", "", "nav_logo", "排版样式");
        swpas[6] = new ShoveWebPartAttribute_Text("标题CSS样式", "", "menu", "标题CSS样式");
        swpas[7] = new ShoveWebPartAttribute_Text("登陆导航CSS样式", "", "menu_top", "登陆导航CSS样式");

        swpas[8] = new ShoveWebPartAttribute_Image("Logo图片", "", "images/UserControls/logo.jpg", "Logo图片");
        swpas[9] = new ShoveWebPartAttribute_Image("联系电话图片", "", "images/UserControls/ser.jpg", "联系电话图片");
    }

    protected void Page_Load(object sender, EventArgs e)
    {      
        Initlayout();

        if (_Customer != null)
        {
            lbWelcome.Visible = true;
            lbWelcome.Text = "欢迎<font color=red>" + _Customer.CustomerName + "</font>继续光顾！";

            lblogin.Visible = false;    //登录提示隐藏
            lbReg.Visible = false;      //注册提示隐藏
        }
        else
        {
            lbExit.Visible = false;
        }

        if (_Site.ID == 1)
        {
            imglogo.Src = "~/images/UserControls/top_logo.jpg";
        }
        else
        {
            imglogo.Src = "~/images/UserControls/top_logo2.jpg";
        }
    }

    private void Initlayout()
    {
        tabctr.Width = swpAttributes[0];

        //根据URL来判断当前页面
        String PN = Shove._Web.Utility.GetRequest("PN");

        if (String.IsNullOrEmpty(PN))
        {
            td_01.Width = "98";
            td_01.Style.Add(HtmlTextWriterStyle.BackgroundImage, "images/UserControls/index_1_02.jpg");
            a_01.Attributes.Add("class", "Meun1");
        }
        else if (PN.Equals("goods_search_list"))
        {
            td_02.Width = "98";
            td_02.Style.Add(HtmlTextWriterStyle.BackgroundImage, "images/UserControls/index_1_02.jpg");
            a_02.Attributes.Add("class", "Meun1");
        }
        else if (PN.Equals("member_home") || PN.Equals("Login") || PN.Equals("Good_Center") || PN.Equals("Address_Management") || PN.Equals("member_homeEditCustomerInfo") || PN.Equals("member_homeEditPassword") || PN.Equals("member_homeConsult") || PN.Equals("member_homeComment") || PN.Equals("member_homeOrder"))
        {
            td_03.Width = "98";
            td_03.Style.Add(HtmlTextWriterStyle.BackgroundImage, "images/UserControls/index_1_02.jpg");
            a_03.Attributes.Add("class", "Meun1");
        }
        else if (PN.Equals("Service"))
        {
            td_04.Width = "98";
            td_04.Style.Add(HtmlTextWriterStyle.BackgroundImage, "images/UserControls/index_1_02.jpg");
            a_04.Attributes.Add("class", "Meun1");
        }
        else if (PN.Equals("about_us"))
        {
            td_05.Width = "98";
            td_05.Style.Add(HtmlTextWriterStyle.BackgroundImage, "images/UserControls/index_1_02.jpg");
            a_05.Attributes.Add("class", "Meun1");
        }
    }

    protected void lbExit_Click(object sender, EventArgs e)
    {
        Session.RemoveAll();
        Response.Redirect("Default.aspx");
    }
}
